// jsencryptKey.ts
import JSEncrypt from 'jsencrypt'

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJzdqhsVK1azCM44B7EovbKBS5pmXjwhitgjAWaGt9b4a7nJ5A1EvIeIYKMC19kxJnGlgfvBHseNyEXZYF8FCVVFwYTD82py3kstDsk6QoLtDvdNEC3RQj0HQ/zVfWtkGYsdY+uJ4/nWOfHWqPwiwbqkElbCvqCmH7BaiW+ArjFQIDAQAB';// 生成的公钥
const privateKey='';// 生成的私钥

// 加密
export function Encrypt(txt: string) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function Decrypt(txt: string) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
